#include<bits/stdc++.h>
using namespace std;
struct block{
	bool type;
	int pos,len;
};
list<block> a;
list<block>::iterator it;
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	int n,tem,now=-1;
	block t;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>tem;
		if(tem!=now){
			now=tem;
			t.type=tem;
			t.pos=i;
			t.len=1;
			a.push_back(t);
			it=a.end();
			it--;
		}
		else{
			(*it).len++;
		}
	}
	while(!a.empty()){
		for(it=a.begin();it!=a.end();it++){
			cout<<(*it).pos<<" ";
			(*it).pos++;
			(*it).len--;
			if((*it).len==0){
				a.erase(it);
			}
		}
		cout<<endl;
	}
	return 0;
}
